package com.example.tree.mapper;

import com.example.tree.domain.dto.TreePageDTO;
import com.example.tree.domain.po.AncientTree;
import com.example.tree.domain.vo.*;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.awt.image.BufferedImage;
import java.util.List;

public interface TreeMapper {

    /**
     * 添加古树信息
     * @param ancientTree
     */
    void insert(AncientTree ancientTree);

    /**
     * 更新古树二维码
     * @param url
     * @param treeId
     */
    @Update("update ancient_tree set qr_code_url = #{url} where tree_id = #{treeId}")
    void updateQrCode(@Param("url")String url, @Param("treeId")Integer treeId);

    /**
     * 添加古树图片
     * @param treeId
     * @param urls
     */
    void insertImages(@Param("treeId") Integer treeId, @Param("urls") List<String> urls);

    /**
     * 获取区域古树位置信息
     * @param level
     * @param code
     * @return
     */
    List<MarkersVO> selectTreeMarkers(@Param("level") String level, @Param("code")String code);

   @Select("select tree_id,chinese_name,scientific_name,family_name,genus_name," +
           "estimated_age,protection_level,gps_longitude,gps_latitude," +
           "province_name,city_name,district_name,location_address,description," +
           "qr_code_url,create_time,update_time from ancient_tree where tree_id = #{treeId}")
    AncientTree selectTreeDetail(Integer treeId);

    // 古树属名数量统计功能
   List<TreeGenusCountVO> selectTreeGenusCount(String level, String code);

   List<TreeFamilyCountVO> selectTreeFamilyCount(String level, String code);

   // 古树保护级别数量统计功能
    List<TreeProtectionCountVO> selectTreeProtectionCount(String level, String code);

    /**
     * 获取古树列表
     * @param treePageDTO
     * @return
     */
    Page<TreeListVO> selectTreeInfo(TreePageDTO treePageDTO);

    void delete(Integer[] ids);
}
